package net.huashitong.synthetical.question.service;


import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.synthetical.question.dao.SupervisionLogDao;
import net.huashitong.synthetical.question.entity.SupervisionLog;
import net.huashitong.synthetical.question.filter.TaskLogFilter;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 催办记录serviec
 */

/**
 * 催办记录service
 */

@Service
public class SupervisionLogService extends StringPKService<SupervisionLog> {

    @Autowired
    private SupervisionLogDao dao;

    @Autowired
    SysTableService tableService;

    @Override
    protected BaseDao<SupervisionLog, String> getDao() {
        return dao;
    }

    /**
     * 条件查询催办记录
     * @param
     * @return List<SupervisionLog>
     */
    public List<SupervisionLog> getMissionLog(String id)
    {
        return dao.getMissionLog(id);
    }

    @Override
    protected void beforeSave(SupervisionLog obj) {
        obj.setSysId(tableService.updateMaxSysId("t_supervision_log",null));
    }

    public List<SupervisionLog> querySupervisionLogs(TaskLogFilter filter){

        return dao.querySupervisionLogs(filter);
    }

    /**
     * 保存催办记录
     * @param filter
     */
    public void saveCuiBanLog(TaskLogFilter filter)
    {

        if(StringUtils.isBlank(filter.getMethonCode())&&StringUtils.isBlank(filter.getDatatime())&&StringUtils.isBlank(
                filter.getRecord()
        ))
        {
            System.out.println("无添加记录");
        }else {
            SupervisionLog logs  = new SupervisionLog();
            BeanUtils.copyProperties(filter,logs);
            save(logs);
        }

    }

}
